package com.dubbo.consumer;


import com.dubbo.framework.Invocation;
import com.dubbo.framework.protocol.http.HttpClient;
import com.dubbo.framework.proxy.ProxyFactory;
import com.dubbo.provider.api.HelloService;
import lombok.extern.slf4j.Slf4j;

import static com.dubbo.framework.consts.DubboConstant.*;

/**
 * 消费者
 *
 * @author by Mr. Li 2021/4/28 17:50
 */
@Slf4j
public class Consumer {
    public static void main(String[] args) {

        HttpClient httpClient = new HttpClient();

        Invocation invocation = new Invocation(HelloService.class.getName(),
                "sayHello", new Class[]{String.class}, new String[]{"xiaogang"});

        // 发送远程调用
        final String send = httpClient.send(IPADDR, PORT, invocation);

        // 升级成动态代理模式
//        final HelloService helloService = ProxyFactory.getProxy(HelloService.class);
//        final String send = helloService.sayHello("动态代理实在是太帅啦！！！");

        log.info("远程调用成功，返回数据为：{}", send);
    }
}
